perf(queue): coalesce the four event-driven job types by their per-invocation id - #2001
Conversation
…sed on GitHub reReviewStoredPullRequest only checked the STORED state, then spent GitHub budget resyncing files + running readiness/CI reads + re-reviewing even for a PR already closed/merged on GitHub (a dropped `closed` webhook while the relay was down). After the single memoized fetchLivePullRequest, early-exit on a live NON-open state: upsert the live payload to reconcile the stored row, then return before the files + CI reads + review. Reconciling the row lets the next sweep skip it via the existing stored-state guard. Fail-open: only a live non-open state early-exits. Advances #1936.
…vocation id run-agent / notify-deliver / notify-evaluate / submit-draft had no coalesce key, so a duplicate enqueue (webhook redelivery, retried dispatch) queued a second identical job. Each carries a stable per-invocation id (runId / deliveryId / event.dedupKey / draftId), so key off that: coalescing then only ever merges a true duplicate re-enqueue of the SAME job — distinct invocations have distinct ids (distinct keys), and a missing id stays uncoalesced (null), so nothing legitimate is dropped. Advances #1936.
|
Warning 🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨🟨 ⏸️ Gittensory review result - manual review recommendedReview updated: 2026-07-01 07:25:23 UTC
⏸️ Suggested Action - Manual Review
Review summary Nits — 5 non-blocking
Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2001 +/- ##
==========================================
- Coverage 95.66% 95.66% -0.01%
==========================================
Files 220 220
Lines 24453 24465 +12
Branches 8868 8874 +6
==========================================
+ Hits 23394 23404 +10
Misses 436 436
- Partials 623 625 +2
🚀 New features to boost your workflow:
|
Summary
The four event-driven job types —
run-agent,notify-deliver,notify-evaluate,submit-draft— had no coalesce key, so a duplicate enqueue (a webhook redelivery, a retried dispatch) queued a second identical job. Every one of them already carries a stable per-invocation id, so this adds coalesce keys off those:run-agentrunIdnotify-deliverdeliveryIdnotify-evaluateevent.dedupKeysubmit-draftdraftIdBecause the key is the per-invocation id, coalescing only ever merges a true duplicate re-enqueue of the same job — two distinct invocations have distinct ids and therefore distinct keys, so nothing legitimate is ever dropped. A payload missing its id returns
null(uncoalesced) rather than sharing a key.This is the rec #17 half of the #1942 audit's coalesce cluster. Advances #1936.
Notes on the other two recs in that cluster (kept out of this PR):
backfill-*,generate-signal-snapshots, …) already have coalesce keys, so a re-enqueue this tick already coalesces — the "skip" is effectively in place.status IN (pending, processing)): deliberately deferred — coalescing onto an in-flight job is materially riskier (it can swallow an update that must re-run after the current pass), so it deserves its own PR + a recoalesce marker rather than riding along here.Validation
git diff --check,npm run typechecknpm run test:coverage— new test: each type coalesces by its id, distinct ids stay distinct, and a missing id →null(covers both branches of every new case); existing coalesce/priority suites still pass.npm run test:ci,npm audit --audit-level=moderateSafety